Adding To A Dictionary - txt
(
37
actions, 23 KB)
0 Text
➔ filename
»
1
10
34
dictionaryexample.txt
1 Get File at Path
[0 filename]
from Folder »
FileErrorIfNotFound
:
false
ShowFilePicker
:
false
GetFolderContents
:
true
2 Get Text from
[1 File]
»
3 Set Variable
DictionayExample
to
[2 Text]
4 If
[DictionayExample]
does not have any value
5 Ask for Text Input »
AskActionPrompt
:
Key?
6 Set Variable
Key
to
[5 Ask for Input]
7 Ask for Text Input »
AskActionPrompt
:
Value?
8 Set Variable
Value
to
[7 Ask for Input]
9 Text »
{"
[Key]
":"
[Value]
"}
10 Save File
[9 Text]
AskWhereToSave
:
false
SaveFileOverwrite
:
true
FileDestinationPath
:
[0 filename]
11 Otherwise ▵
4
12 Comment
/Start new section to show the dictionary
13 Get Dictionary from
[DictionayExample]
»
14
16
14 Get Dictionary
All Keys
in
[13 Dictionary]
»
15 Repeat with Each in
[14 Dictionary Value]
16 Get Dictionary Value for
[Repeat Item]
in
[13 Dictionary]
»
17 Text
[Repeat Item]
:
[16 Dictionary Value]
18 End Repeat with Each »
19 Show Alert
This is your dictionary: Key:Value
[18 Repeat Results]
AlertActionCancelButtonShown
:
false
20 Comment
/End new section to show the dictionary
21 Ask for Text Input »
AskActionPrompt
:
Key?
22 Set Variable
Key
to
[21 Ask for Input]
23 Comment
Check if key already exists
24 Get Dictionary from
[DictionayExample]
»
25 Get Dictionary
All Keys
in
[24 Dictionary]
»
26 If
[25 Dictionary Value
as Text
]
contains
[Key]
27 Show Alert
This key is already taken.
AlertActionCancelButtonShown
:
false
28 Run Shortcut
Adding To A Dictionary
Workflow
:
{ "workflowName": "Adding To A Dictionary", "isSelf": false }
ShowWorkflow
:
false
29 Otherwise
30 Ask for Text Input »
AskActionPrompt
:
Value?
31 Set Variable
Value
to
[30 Provided Input]
32 Comment
Replace the } add ,"key":"value} to the existing dictionary
33 Replace Text
}
with
,"
[Key]
":"
[Value]
"}
in
[DictionayExample]
»
ReplaceTextCaseSensitive
:
false
34 Save File
[33 Updated Text]
AskWhereToSave
:
false
SaveFileOverwrite
:
true
FileDestinationPath
:
[0 filename]
35 End If ▵
29
36 End If ▵
11